package com.imooc.springbootinterceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web配置类
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
	/**
	 * 添加Web项目的拦截器
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		// 对所有访问路径，都通过MyInterceptor类型的拦截器进行拦截
		registry.addInterceptor(new MyInterceptor()).addPathPatterns("/**");
	}
}
